import request from '@/utils/request'

const api = "https://devapi.qweather.com/v7"
const geoApi="https://geoapi.qweather.com/v2"
const { weatherKey } = require('@/config/constant.js');



/** form和风天气
 *  获取实时天气信息
 *  @param  {String} key
 *  @param  {String} location
 *  @return {String}
 */
export const getWeatherNow = (params) => {
	return request.get(api+'/weather/now', {...params,key:weatherKey})
}

/**
 *  获取空气质量
 *  @param  {String} key
 *  @param  {String} location
 *  @return {String}
 */
export const getAirNow = (params) => {
	return request.get(api+'/air/now', {...params,key:weatherKey})
}

/**
 *  获取近三天天气预报
 *  @param  {String} key
 *  @param  {String} location
 *  @return {String}
 */
export const getThreeDay = (params) => {
	return request.get(api+'/weather/3d', {...params,key:weatherKey})
}

/**
 *  获取灾害预警
 *  @param  {String} key
 *  @param  {String} location
 *  @return {String}
 */
export const getWarningNow = (params) => {
	return request.get(api+'/warning/now', {...params,key:weatherKey})
}  

/**
 *  获取生活指数
 *  @param  {String} key
 *  @param  {String} location
 *  @return {String}
 */
export const getLifeIndex = (params) => {
	return request.get(api+'/indices/1d', {...params,key:weatherKey})
}  


/**
 *  根据经纬度或者城市名字获取城市信息
 *  @param  {String} 
 *  @return {String}
 */
export const getCityInfo = (params) => {
	return request.get(geoApi+'/city/lookup', {...params,key:weatherKey})
}







